<script language="javascript" type="text/javascript">
function moveUp(mid){
	location.href='<?php $Url->href("/menu/moveup/'+mid"); ?>;
}
function moveDown(mid){
	location.href='<?php $Url->href("/menu/movedown/'+mid"); ?>;
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td colspan="5" class="cattitle"><img src="<?php echo $Url->img_src("images/bullet_go.png"); ?>" border="0" align="absmiddle" />Danh sách menu</td>
    </tr>
	<tr>
		<td colspan="5" height="1"></td>
	</tr>
	<?php
	if(is_array($arrMenu) && sizeof($arrMenu)>0){
		$i = 1;
		foreach($arrMenu as $key => $val){
	?>
    <tr class="parentmenu">
      <td colspan="2" align="left" class="txtpadding">
	  <?php
	  if($val['menu_active'] != 1){
	  ?>
		  <a href="<?php echo $Url->href( "menu/active/"+$val['menu_id']); ?>" title="Active"><img src="<?php echo const_Static_Data_Url; ?>images/picture_empty.png" border="0" align="absmiddle" /></a>
	  <?php
	  }else{
	  ?>
		  <a href="<?php echo const_Static_Data_Url; ?>menu/deactive/<?php echo $val['menu_id'] ?>" title="Deactive"><img src="<?php echo const_Static_Data_Url; ?>images/picture_check.png" border="0" align="absmiddle" /></a>
	  <?php
	   }
	  ?>
			  
	  <a href="<?php echo const_Static_Data_Url; ?>menu/edit/<?php echo $val['menu_id'] ?>" title="Edit menu"><?php echo $val['menu_name'] ?></td>
	  <td align="right" width="146" style="padding-right:5px;">
			  <?php if($i != 1){ ?>
	 <a href="javascript:moveUp(<?php echo $val['menu_id']; ?>)"> <img src="<?php echo const_Static_Data_Url; ?>images/sortasc.png" border="0" align="absmiddle" title="Move up" /></a>
	  		<?php }if($i < sizeof($arrMenu)){ ?>
	  <a href="javascript:moveDown(<?php echo $val['menu_id']; ?>)"><img src="<?php echo const_Static_Data_Url; ?>images/sortdesc.png" border="0" align="absmiddle" title="Move down" /></a>
	  <?php } ?>
	  </td>
    </tr>
	<?php
			if(sizeof($val['children']) > 0){
				$x = 1;
				foreach($val['children'] as $child_key => $child_val){
	?>
			<tr class="rowsubmenu">
			  <td colspan="2" align="left" class="submenu">
			  <?php
			  if($child_val['menu_active'] != 1){
			  ?>
				  <a href="<?php echo const_Static_Data_Url; ?>menu/active/<?php echo $child_val['menu_id'] ?>" title="Active"><img src="<?php echo const_Static_Data_Url; ?>images/uncheck.png" border="0" align="baseline" style="padding-left:20px;" /></a>
			  <?php
			  }else{
			  ?>
				  <a href="<?php echo const_Static_Data_Url; ?>menu/deactive/<?php echo $child_val['menu_id'] ?>" title="Deactive"><img src="<?php echo const_Static_Data_Url; ?>images/check.png" border="0" align="baseline" style="padding-left:20px;" /></a>
			  <?php
			   }
			  ?>

			<a href="<?php echo const_Static_Data_Url; ?>menu/edit/<?php echo $child_val['menu_id'] ?>" title="Edit menu"><?php echo $child_val['menu_name']; ?></a></td>
			  <td align="left">
			  <?php if($x != 1){ ?>
	  <a href="javascript:moveUp(<?php echo $child_val['menu_id']; ?>)"><img src="<?php echo const_Static_Data_Url; ?>images/sortasc.png" border="0" align="absmiddle" title="Move up" /></a>
	  		<?php }if($x < sizeof($val['children'])){ ?>
	  <a href="javascript:moveDown(<?php echo $child_val['menu_id']; ?>)"><img src="<?php echo const_Static_Data_Url; ?>images/sortdesc.png" border="0" align="absmiddle" title="Move down" /></a>
	  <?php } ?>
			  </td>
			</tr>
    <?php
					$x++;
				}
			}
			$i ++;
		}
	?>
	<tr>
		<td colspan="5" height="5"></td>
	</tr>

	<?php
	}
	?>
  </tbody>
</table>
